From 59d9a14fc638469ed1803004108bcd9085c46e5b Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 8 Jan 2010 11:45:34 +0000 Subject: [PATCH] libxenlight: returns errors if xc and/or xs has not been initialized properly. fixed segfault when xenstore or xc are not available. Signed-off-by: Vincent Hanquez --- tools/libxl/libxl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 8194623bf6..a49371540c 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -45,7 +45,17 @@ int libxl_ctx_init(struct libxl_ctx *ctx, int version) return ERROR_NOMEM; ctx->xch = xc_interface_open(); + if (ctx->xch == -1) { + free(ctx->alloc_ptrs); + return ERROR_FAIL; + } + ctx->xsh = xs_daemon_open(); + if (!ctx->xsh) { + xc_interface_close(ctx->xch); + free(ctx->alloc_ptrs); + return ERROR_FAIL; + } return 0; } -- 2.30.2